﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace Wsp365.Anonymous
{
    public static class ListHelper
    {
        public static void AddAnonymousAccess(this SPList list, SPBasePermissions additionalPerms)
        {            
            if (!list.HasUniqueRoleAssignments)
            {
                list.BreakRoleInheritance(true);
            }
            list.AnonymousPermMask64 = SPBasePermissions.OpenItems;
            list.Update();
            list.AnonymousPermMask64 = SPBasePermissions.Open |
                SPBasePermissions.OpenItems |
                SPBasePermissions.ViewFormPages |               
                additionalPerms;
            list.Update();
        }

    }
}
